#pragma once
#include <iostream>
using namespace std;
#include <assert.h>

class Date
{
	friend ostream& operator<<(ostream& out, const Date& d);
	friend istream& operator>>(istream& in,  Date& d);
public:
	Date(int year = 2000, int month = 1,int day = 1);
	void printf();
	int GetMonthDay(int year, int month)
	{
		static int monthday[] = { -1,31,28,31,30,31,30,31,31,30,31,30,31 };
		assert(month > 0 && month < 13);
		if(month == 2 && (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
		{
			return 29;
		}
		else
		{
			return monthday[month];
		}
	}
	bool operator<(const Date& d)const;
	bool operator<=(const Date& d)const;
	bool operator>(const Date& d)const;
	bool operator>=(const Date& d)const; 
	bool operator==(const Date& d)const;
	bool operator!=(const Date& d)const;

	Date& operator+=(int day);
	Date operator+(int day)const;
	Date& operator-=(int day);
	Date operator-(int day)const;
	//int operator-(const Date& d)const;
	int operator-(const Date& d) const;
	Date& operator++();
	Date operator++(int);
	Date& operator--();
	Date operator--(int);
	bool CheckDate();

	

private:
	int _year;
	int _month;
	int _day;
};

ostream& operator<<(ostream& out, const Date& d);
istream& operator>>(istream& in,  Date& d);
